package com.we823.project.model.repo;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Proxy;

import com.we823.project.model.BaseModelWithDate;
import com.we823.project.model.sys.CalculateModel;

@Entity
@Table(name="repo_material")
@Proxy(lazy=false)
@NamedQuery(name="MaterialModel.findAll", query="SELECT m FROM MaterialModel m")
public class MaterialModel extends BaseModelWithDate {
	
	private static final long serialVersionUID = 1L;

	private String name;
	private String code;

	@ManyToOne(cascade=CascadeType.REFRESH,fetch=FetchType.EAGER,optional=false)
	@JoinColumn(name="category_id",nullable=false,unique=false)
	@NotFound(action=NotFoundAction.IGNORE)
	private CategoryModel category;
	
	/**
	 * 芯数
	 */
	private Integer wire=0;
	/**
	 * 型号
	 */
	private String model;
	/**
	 * 颜色
	 */
	private String color;
	
	private String specification;
	
	private String fullname;
	/**
	 * 单位
	 */
	private String unit;
	
	private String editor;

	private String inputer;
	@Column(name="card_name")
	private String cardname;
	
	@Transient
	private CalculateModel calculateModel;
	@Transient
	private String categoryName;

	@Transient
	private List<MaterialBomModel> materialBoms;
	public MaterialModel() {
	}

	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getEditor() {
		return this.editor;
	}

	public void setEditor(String editor) {
		this.editor = editor;
	}

	public String getInputer() {
		return this.inputer;
	}

	public void setInputer(String inputer) {
		this.inputer = inputer;
	}

	public String getName() {
		if (name==null) {
			name="";
		}
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUnit() {
		return this.unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public CategoryModel getCategory() {
		return this.category;
	}

	public void setCategory(CategoryModel category) {
		this.category = category;
	}

	public Integer getWire() {
		return wire;
	}

	public void setWire(Integer wire) {
		this.wire = wire;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}

	public CalculateModel getCalculateModel() {
		return calculateModel;
	}

	public void setCalculateModel(CalculateModel calculateModel) {
		this.calculateModel = calculateModel;
	}

	public String getSpecification() {
		return specification;
	}

	public void setSpecification(String specification) {
		this.specification = specification;
	}

	public String getFullname() {
		if(fullname==null){
			fullname=model+" "+specification;
		}
		return fullname;
	}

	public void setFullname(String fullname) {
		this.fullname = fullname;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public String getCardname() {
		return cardname;
	}

	public void setCardname(String cardname) {
		this.cardname = cardname;
	}

	public List<MaterialBomModel> getMaterialBoms() {
		return materialBoms;
	}

	public void setMaterialBoms(List<MaterialBomModel> materialBoms) {
		this.materialBoms = materialBoms;
	}
	
}